import java.util.Scanner;

public class Array {

    public static void main(String[] args) {
/*        int[] ages = {12, 13, 22, 32, 24, 22};
        for (int i = 0; i < ages.length; i++) {
            System.out.println(ages[i]);
        }*/

        //静态初始化
        //int[] ages = {1, 2, 3, 4};

        //动态初始化
/*        int[] age;
        age=new int[6];*/
        /*int[] age = new int[3];
        age[0] = 1;
        age[1] = 2;
        age[2] = 3;

        for (int i = 0; i < age.length; i++) {
            System.out.println(age[i]);
        }*/

        //练习1
        /*int[] a = {1, 2, 3, 4};
        int[] b = new int[4];
        b[0] = 5;
        b[1] = 6;
        b[2] = 7;
        b[3] = 8;
        int len = a.length + b.length;
        int[] c = new int[len];
        for (int i = 0; i < len; i++) {
            if (i < a.length) {
                c[i] = a[i];
            } else {
                c[i] = b[i - a.length];
            }
        }
        for (int i = 0; i < len; i++) {
            System.out.println(c[i]);
        }*/

        //练习2
        double average;
        int sum = 0;
        for (int i = 1; i <= 100; i++) {
            sum += i;
        }
        System.out.println("sum的总和=" + sum);
        average = (double) sum / 100;
        System.out.println("average的值=" + average);
        for (int i = 0; i <= 100; i++) {
            if (i > average) {
                System.out.println(i);
            }
        }


        //for-each语句输出
        int[] a = {1, 2, 3};
        for (int element : a) {
            System.out.println(element);
        }
    }
}
